package com.rerun.phone.memberuser;

import com.baomidou.mybatisplus.plugins.Page;
import com.rerun.common.anno.ResponseExceptionReturn;
import com.rerun.common.bean.Rest;
import com.rerun.common.controller.SuperController;
import com.rerun.entity.ChatUser;
import com.rerun.enums.ChatRecordsStatus;
import com.rerun.service.IChatJobService;
import com.rerun.service.IChatRecordsService;
import com.rerun.service.IChatService;
import com.rerun.vo.memberUser.ChatRecordsSearchVo;
import com.rerun.vo.memberUser.ChatRecordsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * The type Chat user controller.
 *
 * @author dax.
 * @version v1.0
 * @since 2017 /10/30 16:42
 */
@Api(value = "求职端-聊天帐号获取,聊天记录相关", description = "求职端-聊天帐号获取,聊天记录相关")
@RestController
@RequestMapping("/memberApi/chatUser")
public class ChatUserController extends SuperController {
    @Resource
    private IChatService iChatService;
    @Resource
    private IChatRecordsService iChatRecordsService;
    @Resource
    private IChatJobService chatJobService;
    /**
     * Gets own chat account.
     *
     * @param currentMemberId the current member id
     * @return the own chat account
     */
    @ApiOperation(value = "求职端聊天帐号获取", notes = "求职端聊天帐号获取", httpMethod = "POST")
    @RequestMapping(value = "/chat/userInfo/{currentMemberId}", method = RequestMethod.POST)
    @ResponseExceptionReturn
    public Rest getOwnChatAccount(@PathVariable("currentMemberId") String currentMemberId) {
        return Rest.okData(iChatService.getMemberChatUser(currentMemberId));
    }
    /**
     * Gets own chat account.
     *
     * @param currentMemberId the current member id
     * @return the own chat account
     */
    @ApiOperation(value = "院长端-求职聊天帐号获取", notes = "院长端求职聊天帐号获取", httpMethod = "POST")
    @RequestMapping(value = "/chat/park/userInfo/{currentMemberId}", method = RequestMethod.POST)
    @ResponseExceptionReturn
    public Rest getChatAccountForPark(@PathVariable("currentMemberId") String currentMemberId) {
        ChatUser chatUser= (ChatUser) iChatService.getMemberChatUser(currentMemberId);
        return Rest.okData(chatUser.getUserName());
    }
    @ApiOperation(value = "聊天记录", notes = "聊天记录,沟通过的职位", httpMethod = "POST")
    @RequestMapping(value = "/chat/chatRecords/{currentMemberId}/{pageNumber}", method = RequestMethod.POST)
    @ResponseExceptionReturn
    public Rest getOwnChatRecords(@PathVariable("currentMemberId") String currentMemberId, @PathVariable("pageNumber") Integer pageNumber, @RequestParam(defaultValue = "15") Integer pageSize) {
        ChatRecordsSearchVo chatRecordsSearchVo = new ChatRecordsSearchVo();
        chatRecordsSearchVo.setMemberId(currentMemberId);
        chatRecordsSearchVo.setUserStatus(ChatRecordsStatus.IS_SHOW.getKey());

        Page<ChatRecordsVo> chatRecordsVoPage = getPage(pageNumber, pageSize);
        return Rest.okData(chatJobService.selectRecordsList(chatRecordsSearchVo, chatRecordsVoPage));
    }

}
